<template>
    <div class="canvaContainer" ref="test" style="height:40vh;"></div>
</template>

<script>
import * as echarts from 'echarts';
export default {
    methods: {
        drawEcharts() {
            var myChart = echarts.init(this.$refs.test, 'dark');

            // 指定图表的配置项和数据
            var option = {
                backgroundColor: '#121626',
                color: ['#DE6173', '#333FFF', '#23B899'],
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross'
                    }
                },
                legend: {
                    data: ['正面舆情数量', '负面舆情数量']
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: [
                        '5:00',
                        '8:00',
                        '9:00',
                        '11:00',
                        '14:00',
                        '17:00',
                        '20:00',
                        '23:00'
                    ]
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '正面舆情数量',
                        type: 'line',
                        smooth: 0.3,
                        lineStyle: {
                            width: 1
                        },
                        areaStyle: {},
                        emphasis: {
                            focus: 'series'
                        },
                        data: [440, 560, 1260, 550, 280, 950, 300, 250]
                    },
                    {
                        name: '负面舆情数量',
                        type: 'line',
                        smooth: 0.3,
                        lineStyle: {
                            width: 1
                        },
                        areaStyle: {},
                        emphasis: {
                            focus: 'series'
                        },
                        data: [260, 560, 450, 380, 450, 300, 250, 440]
                    }
                ]
            };

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        }
    },
    mounted() {
        this.drawEcharts();
    }
};
</script>

<style lang="scss" scoped>
.canvaContainer {
    box-sizing: border-box;
    padding: 20px 10px 0;
    width: 100%;
}
</style>
